//package main_com.Controlers.date.new_;
//
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import jakarta.servlet.http.HttpSession;
//import main_com.mapper.DateMapper;
//import main_com.pojo.LoginBean;
//import main_com.pojo.LookDateBean;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import java.util.ArrayList;
//
//@Controller
//@RequestMapping("/LookDateController")
//public class LookDateController {
//
//    @Autowired
//    DateMapper dateMapper;
//
//    @RequestMapping("/lookDate")
//    protected void lookDate(HttpServletRequest request, HttpServletResponse response) {
//        try {
//            String userName = "";
//            HttpSession session = request.getSession();
//            ArrayList login = (ArrayList) session.getAttribute("login");
//
//            if (login == null || login.size() == 0) {
//                response.sendRedirect("http://localhost/login.jsp");
//                return;
//            } else {
//                for (int i = login.size() - 1; i >= 0; i--) {
//                    LoginBean nn = (LoginBean) login.get(i);
//                    userName = nn.getUserName();
//                }
//            }
//
//            // 获取当前页码，默认是第1页，如果请求中带有page参数则使用该参数指定的页码
//            String pageParam = request.getParameter("page");
//            int currentPage = (pageParam!= null)? Integer.parseInt(pageParam) : 1;
//            int pageSize = 5; // 每页显示5条日程数据，可根据实际需求调整
//            int offset = (currentPage - 1) * pageSize;
//
//            // 获取总记录数
//            int totalCount = dateMapper.countDateByUserName(userName);
//            int totalPages = (int) Math.ceil((double) totalCount / pageSize);
//
//            // 获取当前页的日程数据
//            ArrayList<LookDateBean> datelist = dateMapper.getDateByUserNameWithPagination(userName, offset, pageSize);
//
//            // 将日程数据列表、当前页码、总页数存入会话，方便前端页面获取使用
//            session.setAttribute("datelist", datelist);
//            session.setAttribute("currentPage", currentPage);
//            session.setAttribute("totalPages", totalPages);
//
//            response.sendRedirect("http://localhost/dateManager/lookDate.jsp");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//    }
//}